package memleak.test.com.testlist;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;


/**
 * Created by runrun on 2017/2/13.
 * view的工厂，用于产生view
 */

public class ViewFactory  {

    public void setup() {
    }

    private static   ViewFactory  instance = null;

    public static ViewFactory getViewFactory() {
        if(instance == null){
            instance = new ViewFactory();
        }
        return instance;
    }

    public View output(Context context, Constant.VIEW_TYPE viewType) {
        if (null == context) {
            return null;
        }
        View view = null;
        Constant.VIEW_TYPE type = viewType;
        switch (type) {
            case IMAGE_VIEW:
                view = new ImageView(context);
                break;
            case TEXT_VIEW:
                view = new TextView(context);
                break;
            case LEFT_LAYOUT:
                view = new LeftLayout(context);
                break;
            case BOTTOM_LAYOUT:
                break;
//            case MTEXT_VIEW:
//                view = new MarqueeTextView(context);
//                break;
//            case AD_VIEW:
//                view = new AdView(context);
//                break;
//            case MAIN_LAYOUT:
//                view = new MainLayout(context);
//                break;
            case LABEL_VIEW:
                view = new LabelView(context);
                break;
            case TAB_VIEWPAGER:
                view = new TabViewPager(context);
                break;
            case CHANNEL_LAYOUT:
                view = new ChannelLayout(context);
                break;
            case CHANNELRECYCLER_VIEW:
                view = new ChannelRecyclerView(context);
                break;
            case CHANNEL_VIEW:
                view = new ChannelView(context);
                break;
        }

        return view;
    }

    public void destroy() {

    }
}
